////////////////////////////////////////////////////////////////////////////
//
//  Crytek Engine Source File.
//  Copyright (C), Crytek Studios, 2001-2005.
// -------------------------------------------------------------------------
//  File name:   FlowGraphNode.h
//  Version:     v1.00
//  Created:     7/4/2005 by Timur.
//  Compilers:   Visual Studio.NET 2003
//  Description: 
// -------------------------------------------------------------------------
//  History:
//
//  Modified:    22/2/2008 Visual FG Debugging by Jan Mueller
////////////////////////////////////////////////////////////////////////////

#ifndef __FlowGraphNode_h__
#define __FlowGraphNode_h__
#pragma once

#include <IEntitySystem.h>
#include <IFlowSystem.h>

#include "HyperGraphNode.h"

class CFlowNode;
class CEntityObject;

//////////////////////////////////////////////////////////////////////////
class CFlowNode : public CHyperNode
{
	friend class CFlowGraphManager;

public:
	CFlowNode();
	virtual ~CFlowNode();

	//////////////////////////////////////////////////////////////////////////
	// CHyperNode implementation.
	//////////////////////////////////////////////////////////////////////////
	virtual void Init();
	virtual void Done();
	virtual CHyperNode* Clone();
	virtual const char* GetDescription();
	virtual void Serialize( XmlNodeRef &node,bool bLoading, CObjectArchive* ar);
	virtual void SetName( const char *sName );
	virtual void OnInputsChanged();
	virtual void OnEnteringGameMode();
	virtual void Unlinked( bool bInput );
	virtual CString GetPortName( const CHyperNodePort &port );
	virtual void PostClone( CBaseObject *pFromObject,CObjectCloneContext &ctx );
	virtual Gdiplus::Color GetCategoryColor();
	virtual void DebugPortActivation(TFlowPortId port, const char *value);
	virtual bool IsPortActivationModified(const CHyperNodePort *port = NULL);
	virtual void ClearDebugPortActivation();
	virtual CString GetDebugPortValue(const CHyperNodePort &pp);
	virtual void ResetDebugPortActivation(CHyperNodePort* port);
	virtual bool IsDebugPortActivated(CHyperNodePort* port);
	virtual bool IsObsolete() const { return m_flowSystemNodeFlags & EFLN_OBSOLETE; }
	virtual TFlowNodeId GetTypeId();
	//////////////////////////////////////////////////////////////////////////

	//////////////////////////////////////////////////////////////////////////
	// FlowSystem Flags. We don't want to replicate those again....
	//////////////////////////////////////////////////////////////////////////
	uint32 GetCoreFlags() const { return m_flowSystemNodeFlags & EFLN_CORE_MASK; }
	uint32 GetCategory() const { return m_flowSystemNodeFlags & EFLN_CATEGORY_MASK; }
	uint32 GetUsageFlags() const { return m_flowSystemNodeFlags & EFLN_USAGE_MASK; }
	const char* GetCategoryName() const;
	const char* GetUIClassName() const;

	void SetFromNodeId( TFlowNodeId flowNodeId );

	void SetEntity( CEntityObject *pEntity );
	CEntityObject* GetEntity() const;



	// Takes selected entity as target entity.
	void SetSelectedEntity();
	// Takes graph default entity as target entity.
	void SetDefaultEntity();
	CEntityObject* GetDefaultEntity() const;

	// Returns IFlowNode.
	IFlowGraph* GetIFlowGraph() const;

	// Return ID of the flow node.
	TFlowNodeId GetFlowNodeId() { return m_flowNodeId; }

	void SetInputs( bool bActivate, bool bForceResetEntities = false);
	virtual CVarBlock* GetInputsVarBlock();

	virtual CString GetTitle() const;

	virtual IUndoObject* CreateUndo();
protected:
	virtual bool IsEntityValid () const;
	virtual CString GetEntityTitle() const;

protected:
	GUID m_entityGuid;
	_smart_ptr<CEntityObject> m_pEntity;
	uint32 m_flowSystemNodeFlags;
	TFlowNodeId m_flowNodeId;
	const char* m_szUIClassName;
	const char* m_szDescription;
	std::map<TFlowPortId, string> m_portActivationMap;
	std::vector<TFlowPortId> m_debugPortActivations;
};


#endif // __FlowGraphNode_h__
